#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

/******************************************************************
Main Function
******************************************************************/
int main(int argc, char* argv[])
{
	int i = 0;
	char   param[256] = {0};
	char   tmpName[1024] = {0};

	for (i = strlen(argv[0]) - 1; i > 0 ; i--)
	{
		if ('/' == argv[0][i])
		{
			i = i + 1;
			break;
		}
	}

	memcpy(tmpName, argv[0], i);

	snprintf(param, sizeof(param), "src=\"$(pwd)\" && cd \"%s\" && pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY \"$(pwd)/start.sh\" && cd \"$src\"", tmpName);
	for (i = 1; i < argc; i++)
	{
		snprintf(param + strlen(param), sizeof(param) - strlen(param), " \"%s\"", argv[i]);
	}
	
    system(param);

	return 0;
}


